/*
package com.lvyq.qrobot.server;

import com.lvyq.qrobot.common.HttpUrlConstant;
import com.lvyq.qrobot.entity.*;
import com.lvyq.qrobot.model.send.SendParam;
import com.lvyq.qrobot.repository.AudioRepository;
import com.lvyq.qrobot.repository.JueWeiRepository;
import com.lvyq.qrobot.repository.SongRepository;
import com.lvyq.qrobot.repository.UserRepository;
import com.lvyq.qrobot.util.CommonUtil;
import com.lvyq.qrobot.util.HttpClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

*/
/**
 * @author lvyq
 * @version 1.0
 * Create by 2024-05-21 15:03
 *//*

@Component
public class UserMsgServer {

    public static UserRepository userRepository;

    public static SongRepository songRepository;

    public static JueWeiRepository jueWeiRepository;

    public static AudioRepository audioRepository;

    @Autowired
    public void setUserRepository(UserRepository userRepository) {
        UserMsgServer.userRepository = userRepository;
    }

    @Autowired
    public void setSongRepository(SongRepository songRepository) {
        UserMsgServer.songRepository = songRepository;
    }

    @Autowired
    public  void setJueWeiRepository(JueWeiRepository jueWeiRepository) {
        UserMsgServer.jueWeiRepository = jueWeiRepository;
    }

    @Autowired
    public  void setAudioRepository(AudioRepository audioRepository) {
        UserMsgServer.audioRepository = audioRepository;
    }

    */
/**
     * @description 回复消息
     * @author lvyq
     * @param[1] instruct
     * @throws
     * @time 2024-05-21 15:08
     *//*

    public static void sendMsg(UserEntity user, InstructEntity instruct) {
        SendParam param = new SendParam();
        param.setGroup_id(user.groupId);
        if (instruct.getName().endsWith("打卡")){
            singIn(user, instruct.content, param);
        }

        if (instruct.getName().endsWith("菜单")){
            param.setMessage(instruct.getContent());
            HttpClientUtil.doPostJson(HttpUrlConstant.send_group_msg,param);
        }

        //个人信息
        if (instruct.getName().endsWith("个人")){
            userInfo(user, instruct.content, param);
        }

    }

    */
/**
     * @description 打卡
     * @author lvyq
     * @throws
     * @time 2024-05-22 10:47
     *//*

    private static void singIn(UserEntity user,String content,SendParam param) {
        String msg="";
        if (user.getIsSignIn()==1){
            //已打卡
            msg="[CQ:at,qq="+user.userId.toString()+"] \n" +
                    "[CQ:face,id=38]您今日已打卡,请勿重复打卡";
        }else {
            msg= content.replace("{QQ}",user.userId.toString()).replace("{jinbi}","x1000")
                    .replace("{cbt}","x3");
            user.setJinbi(user.jinbi+1000);
            //修改状态
            user.setIsSignIn(1);
            //TODO 爵位判断
            //获取爵位
            List<JueWeiEntity> jueWeiList = jueWeiRepository.findAll();
            List<Integer> jingyans = new ArrayList<>();
            for (JueWeiEntity jueWei:jueWeiList){
                jingyans.add(jueWei.getJingYanVal());
            }
            user.setJingyan(user.jingyan+100);
            jueWeiCheck(jingyans,user);
            userRepository.save(user);
        }

        param.setMessage(msg);
        param.setGroup_id(user.groupId);
        HttpClientUtil.doPostJson(HttpUrlConstant.send_group_msg,param);
    }

    */
/**
     * @description 爵位判断
     * @author lvyq
     * @param[1] jingyans
     * @param[2] user
     * @throws
     * @time 2024-05-22 13:55
     *//*

    private static void jueWeiCheck(List<Integer> jingyans, UserEntity user) {
        for (int i=0;i<jingyans.size();i++){
            if (user.getJingyan()>=jingyans.get(i) && user.getJingyan()<jingyans.get(i+1)){
                JueWeiEntity jueWei = jueWeiRepository.findByDengJi(i);
                user.setDengji(i);
                user.setJuewei(jueWei.getName());
            }
        }
    }

    */
/**
     * @description 个人信息
     * @author lvyq
     * @param[1] param 
     * @param[2] sendMsg
     * @throws 
     
     * @time 2024-05-22 10:43
     *//*

    private static void userInfo(UserEntity user,String content,SendParam param) {

        //获取用户信息
        content=content.replace("{QQ}",user.userId.toString())
                .replace("{nickName}",user.nickName)
                .replace("{juewei}",user.juewei)
                .replace("{meili}",user.meili.toString())
                .replace("{zhanli}",user.zhanli.toString())
                .replace("{zuoji}",user.zuoqi)
                .replace("{jinbi}",user.jinbi.toString());
        param.setMessage(content);
        param.setGroup_id(user.groupId);
        HttpClientUtil.doPostJson(HttpUrlConstant.send_group_msg,param);
    }
}
*/
